package com.suntront.lib_db.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.suntront.lib_db.table.UserT;

import java.util.List;


/**
 *
 */
@Dao
public interface UserDao {
    //插入多条数据
    @Insert
    void insertUsers(List<UserT> userTS);

    /**
     * 获取多个册本下的待上传数据
     *
     * @param rosterIds
     * @return
     */
    @Query("SELECT * FROM UserT WHERE rosterId IN (:rosterIds) And isUpLoad = 'true'")
    List<UserT> queryUpLoadByRosterId(int[] rosterIds);

    /**
     * 根据rosterId查找任务，并按照rosterOrder排序
     * @param rosterId
     * @return
     */
    @Query("SELECT * FROM UserT WHERE rosterId = :rosterId ORDER BY rosterOrder ASC")
    List<UserT> queryUpLoadByRosterId(int rosterId);

    @Update
    int updateUsers(List<UserT> userTS);

    @Query("DELETE FROM UserT")
    void deleteAll();
}
